convert Agents' receive_web_request to have headers optional

Albert Sun 8 years ago
parent
commit
758573f522

+ 1 - 1
app/models/agents/data_output_agent.rb

@@ -160,7 +160,7 @@ module Agents
160 160
       interpolated['push_hubs'].presence || []
161 161
     end
162 162
 
163
-    def receive_web_request(params, method, format)
163
+    def receive_web_request(params, method, format, headers={})
164 164
       unless interpolated['secrets'].include?(params['secret'])
165 165
         if format =~ /json/
166 166
           return [{ error: "Not Authorized" }, 401]

+ 1 - 1
app/models/agents/twilio_agent.rb

@@ -81,7 +81,7 @@ module Agents
81 81
       "#{server_url}/users/#{user.id}/web_requests/#{id}/#{secret}"
82 82
     end
83 83
 
84
-    def receive_web_request(params, method, format)
84
+    def receive_web_request(params, method, format, headers={})
85 85
       if memory['pending_calls'].has_key? params['secret']
86 86
         response = Twilio::TwiML::Response.new {|r| r.Say memory['pending_calls'][params['secret']], :voice => 'woman'}
87 87
         memory['pending_calls'].delete params['secret']

+ 1 - 1
app/models/agents/user_location_agent.rb

@@ -57,7 +57,7 @@ module Agents
57 57
       end
58 58
     end
59 59
 
60
-    def receive_web_request(params, method, format)
60
+    def receive_web_request(params, method, format, headers={})
61 61
       params = params.symbolize_keys
62 62
       if method != 'post'
63 63
         return ['Not Found', 404]

+ 1 - 1
app/models/agents/webhook_agent.rb

@@ -45,7 +45,7 @@ module Agents
45 45
       }
46 46
     end
47 47
 
48
-    def receive_web_request(params, method, format)
48
+    def receive_web_request(params, method, format, headers={})
49 49
       # check the secret
50 50
       secret = params.delete('secret')
51 51
       return ["Not Authorized", 401] unless secret == interpolated['secret']